package com.spring.springboot.Test;

public class Main {
    public static int result = Integer.MIN_VALUE;

    public static void main(String[] args) {
//        int [] array={1,8,6,2,5,4,8,3,7};
//        int [] array={4,3,2,1,4};
        int[] array = {1, 1};
        int i = get(array);
        System.out.println(i);
    }

    public static int get(int[] array) {
        for (int i = 0; i <= array.length - 1; i++) {
            for (int j = i + 1; j <= array.length - 1; j++) {
                int max = getMax(array, i, j);
                result = Math.max(max, result);
            }
        }
        return result;
    }

    public static int getMax(int[] array, int start, int end) {
        int startResult = array[start];
        int endResult = array[end];
        return (end - start) * Math.min(startResult, endResult);
    }
}
